<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    //数组长度
    //var arr = [1,2,3,4,5];
    //console.log(arr.length);
    //打印数组
    //for(var i = 0;i < arr.length;i++){
        //console.log(arr[i]);
    //}
    //js中数组可以有动态的数组长度
    var arr = ["red","blue","green"];
    arr[arr.length] = "orange";
    console.log(arr);

    //sort默认排列1-9从小到大排
    //var arr1 = [3,2,5,1,9];
    //var childarr1 = arr1.sort();

    //arr.sort() 传入函数，数组元素排序
    //arr.reverse()对数组进行反序处理
    var arr1 = [3,1,2,5,9,15];
    var childarr1 = arr.sort(function(a,b){
        return a-b;
    });
    console.log(childarr1.reverse());
</script>
</html>